# 编译器设置
CC = gcc
CFLAGS = -Iinclude -Wall
LDFLAGS = -lsqlite3

# 源文件和目标文件设置
SRC_DIR = src
SRCS = $(wildcard $(SRC_DIR)/*.c)
OBJS = $(patsubst $(SRC_DIR)/%.c, %.o, $(SRCS))
MAIN = main.c
TARGET = game.exe

# Windows 特殊处理
ifeq ($(OS),Windows_NT)
    LDFLAGS += -L/mingw64/lib  # MinGW-W64 库路径
    SQLITE_LIB = sqlite3.dll
else
    SQLITE_LIB = -lsqlite3
endif

.PHONY: all clean

all: $(TARGET)

$(TARGET): $(OBJS) $(MAIN:.c=.o)
	$(CC) $^ -o $@ $(LDFLAGS)

%.o: $(SRC_DIR)/%.c
	$(CC) $(CFLAGS) -c $< -o $@

$(MAIN:.c=.o): $(MAIN)
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	del /Q *.o $(TARGET) 2>NUL || rm -f *.o $(TARGET)